

from api.ihrm_employees_api import IhrmEmployeesApi

# 定义测试类
from common.assert_tools import common_assert
from common.db_tools import DBTools
from common.get_headers import get_headers


class TestEmpAdd(object):
    # 定义类属性
    req_header = None

    def setup_class(self):
        self.req_header = get_headers()

    def setup(self):
        # del_sql=f"delete * from xx where mobile='13012345678';"
        # DBTools.db_uid(del_sql)
        pass

    def teardown(self):
        # del_sql = f"delete * from xx where mobile='13012345678';"
        # DBTools.db_uid(del_sql)
        pass

    # 添加员工成功--必填参数
    def test01_add_ok(self):
        headers_data = self.req_header
        json_data = {"username": "kity", "mobile": "15036422287", "workNumber": "0008"}
        # 调用自己封装的api,发生添加员工请求
        resp = IhrmEmployeesApi.add_emp(headers_data, json_data)
        print("必填-添加成功:", resp.json())
        # 断言
        common_assert(resp, 200, True, 10000, "操作成功！")

    # # 添加员工成功 --全部参数
    # def test02_add_ok_all(self):
    #     headers_data = {"Content-Type": "application/json",
    #                     "Authorization": "Bearer df2d74b0-a560-43e3-8c8b-53cef037d1b0"}
    #     json_data = {"username": "kity", "mobile": "15036422288", "workNumber": "0008",
    #                  "timeOfEntry": "1993-08-04T08: 00: 00.000+0000",
    #                  "formOfEmployment": 1, "departmentId": "1175311466846683136", "departmentName": None,
    #                  "correctionTime": "2020-01-01T00: 00: 00.000+0000"}
    #     # 调用自己封装的api,发生添加员工请求
    #     resp = IhrmEmployeesApi.add_emp(headers_data, json_data)
    #     print("全部参数-添加成功:", resp.json())
    #     # 断言
    #     common_assert(resp, 200, True, 10000, "操作成功！")
    #
    # # 添加失败--用户名为空
    # def test03_username_none(self):
    #     headers_data = {"Content-Type": "application/json",
    #                     "Authorization": "Bearer df2d74b0-a560-43e3-8c8b-53cef037d1b0"}
    #     json_data = {"username": None, "mobile": "15036422289", "workNumber": "0008",
    #                  "timeOfEntry": "1993-08-04T08: 00: 00.000+0000",
    #                  "formOfEmployment": 1, "departmentId": "1175311466846683136", "departmentName": None,
    #                  "correctionTime": "2020-01-01T00: 00: 00.000+0000"}
    #     # 调用自己封装的api,发生添加员工请求
    #     resp = IhrmEmployeesApi.add_emp(headers_data, json_data)
    #     print("用户名为空-添加失败:", resp.json())
    #     # 断言
    #     common_assert(resp, 200, False, 99999, "抱歉，系统繁忙，请稍后重试！")
